package com.shop.cloud.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class ConfigUtil {

	/**
	 * 延迟返回毫秒时间
	 */
	@Value("${time.inmillseconds}")
	private String timeInMillseconds;

	/**
	 * 是否启用随机异常
	 */
	@Value("${manual.exception.enabled}")
	private String enabled;

	/**
	 * 当对此数取余为0就会抛出异常
	 */
	@Value("${manual.exception.factor}")
	private String factor;

	public boolean isEnabled() {
		return Boolean.getBoolean(enabled);
	}

	public int getFactor() {
		return Integer.parseInt(factor);
	}

	public long getTimeInMillseconds() {
		return Long.parseLong(timeInMillseconds);
	}
	
	/**
	 * 上传文件存储的绝对路径
	 */
	@Value("${upload.absolute.file.path}")
	private String uploadAbsoluteFilePath;

	/**
	 * 访问的base路径
	 */
	@Value("${upload.access.file.path}")
	private String uploadAccessFilePath;

	/**
	 * 默认大小 50M
	 */
	@Value("${upload.file.max.size}")
	private String uploadFileMaxSize;
	@Value("${download.absolute.file.path}")
	private String downloadAbsoluteFilePath;
	@Value("${qiniu.access_key}")
	private String qiNiuAccessKey;
	@Value("${qiniu.secret_key}")
	private String qiNiuSecretKey;
	@Value("${qiniu.bucketname}")
	private String qiNiuBucketname;
	@Value("${qiniu.access_url}")
	private String qiNiuAccessUrl;
	@Value("${jpush.master_secret}")
	private String jpushMasterSecret;
	@Value("${jpush.app_key}")
	private String jpushAppKey;

	public String getQiNiuAccessUrl() {
		return qiNiuAccessUrl;
	}

	public String getQiNiuAccessKey() {
		return qiNiuAccessKey;
	}

	public String getQiNiuSecretKey() {
		return qiNiuSecretKey;
	}

	public String getQiNiuBucketname() {
		return qiNiuBucketname;
	}

	public String getDownloadAbsoluteFilePath() {
		return downloadAbsoluteFilePath;
	}

	public Long getUploadFileMaxSize() {
		return Long.parseLong(uploadFileMaxSize);
	}

	public String getUploadAbsoluteFilePath() {
		return uploadAbsoluteFilePath;
	}

	public String getUploadAccessFilePath() {
		return uploadAccessFilePath;
	}

	public String getJpushAppKey() {
		return jpushAppKey;
	}

	public String getJpushMasterSecret() {
		return jpushMasterSecret;
	}

}
